#pragma once
#include <string>
#include <vector>
#include <fstream>

class StarDictImpl
{
private:
	struct StarDictInfo{
		size_t idx_file_size;
		size_t word_count;
		size_t idx_offset_bits;

		std::string	sametypesequence;

		std::string version;
		std::string bookname;
		std::string author;
		std::string email; 
		std::string	website;
		std::string description;
		std::string	date;
	};

private:
	StarDictInfo dict_info_;
	std::vector<char*> word_index_;

	std::ifstream dict_file_;
	bool compressed_dict;

	char* index_content_;

	char* dict_entry_;
	
	//std::vector<std::string> word_index_;
	//std::vector<std::string> dict_entries_;

public:
	StarDictImpl(void);
	~StarDictImpl(void);

	bool load_ifo(const std::string& path);
	bool load_idx(const std::string& path);
	bool load_dict(const std::string& path);

	char* get_word(size_t index);
	char* get_entry(size_t index);

protected:
	char* get_entry_uncompressed(size_t index);
	char* get_entry_compressed(size_t index);
};
